package nuffzone;

import java.io.IOException;
import javax.servlet.http.*;
import nuffzone.messageManager;
import java.util.*;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

@SuppressWarnings("serial")
public class messageservlet extends HttpServlet {
	@Override
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		
		UserService userService = UserServiceFactory.getUserService();
		com.google.appengine.api.users.User user = userService.getCurrentUser();
		
		messageManager MM = messageManager.getInstance();
		if(user==null){}
		else{
		String name = user.getNickname();
		String message = req.getParameter("message");
		Date date = new Date();
		MM.createMessage(name, message, date);
		}
		resp.sendRedirect("/home.jsp");
		
	}
}